import { Layout } from '@/utils';

const formData = ({ custom1 }) => {
  return [
    {
      layout: Layout.FORM_ITEM_LAYOUT,
      label: 'input',
      field: 'input',
      col: 24,
      options: {
        initialValue: 1 || undefined,
        rules: [
          {
            required: true,
            message: 'Please input name',
          },
        ],
      },
      component: {
        name: 'Input',
        props: {
          placeholder: '请输入',
        },
      },
    },
    {
      layout: Layout.FORM_ITEM_LAYOUT,
      label: 'select',
      field: 'select',
      col: 24,
      options: {
        initialValue: undefined,
        rules: [
          {
            required: true,
            message: 'Please select name',
          },
        ],
      },
      component: {
        name: 'Select',
        props: {
          placeholder: '请选择',
          options: [
            {
              value: '1',
              label: '测试',
            },
          ],
        },
      },
    },
    {
      layout: Layout.FORM_ITEM_LAYOUT,
      label: 'search',
      field: 'search',
      col: 24,
      component: {
        name: 'Input',
        props: {
          placeholder: '请输入',
        },
      },
    },
    {
      layout: Layout.FORM_ITEM_LAYOUT,
      label: 'custom',
      field: 'custom',
      col: 24,
      options: {
        initialValue: custom1.value || undefined,
        rules: [
          {
            required: true,
            validator: () => {
              if (custom1 && custom1.value.length < 10) {
                return Promise.reject(new Error('请输入至少10个字符!'));
              }
              return Promise.resolve();
            },
          },
        ],
      },
      component: 'custom',
    },
  ];
};

export default formData;
